package com.paireach.szwolaiyun.fragmentall;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.paireach.szwolaiyun.R;
import com.paireach.szwolaiyun.sz_util.SharedPreferencesUtil;

import java.lang.ref.WeakReference;

/**
 * Dc收货完成
 * Created by Administrator on 2016/7/4.
 */
public class DcFinishGoodsReceiptFragment extends Fragment {
    public static final String TAG = "DcFinishGoodsReceiptFragment";
    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_dc_finish_goods_receipt, null);
        ((TextView) view.findViewById(R.id.main_userphone)).setText(SharedPreferencesUtil.getValue(getActivity()
                , SharedPreferencesUtil.USER_PHONE));
        ((TextView) view.findViewById(R.id.main_username)).setText(SharedPreferencesUtil.getValue(getActivity()
                , SharedPreferencesUtil.USER_NAME));
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        MyRunnable r = new MyRunnable(this);
        new Handler().postDelayed(r, 1500);
    }

    private static class MyRunnable implements Runnable {

        private WeakReference<DcFinishGoodsReceiptFragment> mm;

        public MyRunnable(DcFinishGoodsReceiptFragment fragment) {
            mm = new WeakReference<>(fragment);
        }

        @Override
        public void run() {
            DcFinishGoodsReceiptFragment fragment = mm.get();
            if (fragment != null) {
                try {
                    fragment.getActivity().finish();
                } catch (Exception e) {

                }
            }
        }
    }
}
